package cn.hesion;
/**
 * ClassName: NumOrderDriver <br/>
 * Description: <br/>
 * date: 2021/2/1 20:21<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * @program: homework1_1
 * @description: 数据排序Driver端
 * @author: hesion
 * @create: 2021-02-01 20:21
 **/
public class NumOrderDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);


        //设置驱动类
        job.setJarByClass(NumOrderDriver.class);

        //设置map和reducer
        job.setMapperClass(NumOrderMap.class);
        job.setReducerClass(NumOrderReducer.class);

        //设置map输出类型
        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(IntWritable.class);

        //设置最终输出kv类型
        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(IntWritable.class);

        // 设置输入和输出路径
        FileInputFormat.setInputPaths(job, new Path("C:\\Users\\admin\\Desktop\\lagouhomework1_1\\code\\homework1_1\\data"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\out"));

        // 提交
        boolean flag = job.waitForCompletion(true);
        System.exit(flag ? 0 : 1);
    }
}
